#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int maxnode = 100005;
const int sigma_size = 26;
char str[MAXN][25];
int tot;
char ch[maxnode][sigma_size];
char val[maxnode];
struct Trie
{
	int sz;
	Trie()
	{
		sz=1;
		memset(ch[0], 0, sizeof(ch[0]));
	}


	int idx(char c)
	{
		return c - 'a';
	}
	void insert(char *s)
	{
		int u = 0, n = strlen(s);
		for (int i = 0; i < n; i++)
		{
			int c = idx(s[i]);
			if (!ch[u][c])
			{
				memset(ch[sz], 0, sizeof(ch[sz]));
				val[sz] = 0;
				ch[u][c] = sz++;
			}
			u = ch[u][c];
			val[u]++;
		}
	}
	void query(char *s)
	{
		int u = 0, n = strlen(s);
		for (int i = 0; i < n; i++)
		{
			putchar(s[i]);
			int c = idx(s[i]);
			if (val[ch[u][c]] == 1)
				return;
			u = ch[u][c];
		}
	}
};
int main()
{
	tot = 0;
	Trie trie;
	while (scanf("%s", str[tot]) != EOF)
	{
		trie.insert(str[tot]);
		tot++;
	} 
	for (int i = 0; i < tot; i++)
	{
		printf("%s", str[i]);
		trie.query(str[i]);
		printf("\n");
	}
	return 0;
}
